public class Test12 {
    public static void main(String[] args) {
        //父类引用子类对象，向上转型，只能调用父类的东西
        Animal dog = new Dog("小小",5,"棕色");
        dog.eat();
        //dog.bark;//error,只能调用父类的方法
    }
    public static void main1(String[] args) {
    Dog dog = new Dog("66",10,"黄色");
    dog.name = "小黄";
    dog.bark();
    dog.eat();
    Cat cat = new Cat();
    cat.name = "小青";
    cat.eat();
    cat.miaoMiao();
    }
}
class Animal{
    String name;
    String color;
    int age;

//    public Animal(String name, String color, int age) {
//        this.name = name;
//        this.color = color;
//        this.age = age;
//    }

    public Animal(String name) {
        this.name = name;
    }

    public Animal() {
    }

    public void eat(){
        System.out.println("在吃");
    }
}
class Dog extends Animal{
//    public Dog(String name, String color, int age) {
//        super(name, color, age);
//    }

    public void eat(){
        System.out.println("dog在吃");
    }
    public Dog(String name,int age,String color) {
        super(name);
        this.color = color;
        this.age = age;
    }

    public void bark(){
        System.out.println(this.name + "汪汪汪");
    }
}
final class Cat extends Animal{//这个类不能再被继承,密封类
//    public Cat(String name, String color, int age) {
//        super(name, color, age);
//    }
    //常量，不能进行修改
    final int a = 10;
    //a = 20;

    public void miaoMiao()
    {
        System.out.println(this.name + "miao~miao~miao~");
    }
}